<%-- 
    Document   : viewPurchase
    Created on : Dec 16, 2009, 9:42:06 AM
    Author     : Administrator
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<script type="text/javascript" src="<%=request.getContextPath()%>/datepicker/js/datepicker.yuic.js">
</script>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/datepicker/css/datepicker.css"/>

<table border="1">
    <tr>
        <th colspan="5">Purchase history: ${product.name}</th>
    </tr>
    <tr>
        <td colspan="5">Unit: ${product.unit}</td>
    </tr>
    <tr>
        <th></th>
        <th>Date</th>
        <th>Quantity</th>
        <th>Price/${product.unit}</th>
        <th>Input by</th>
    </tr>
    <c:forEach var="block" items="${product.blocks}" varStatus="counter">
        <tr>
            <td>${counter.count}</td>
            <td>
                <fmt:formatDate value="${block.purchasedDate}" pattern="MMM d, yyyy"/>
            </td>
            <td>${block.purchasedUnits}</td>
            <td>${block.cost} VND</td>
            <td>${block.manager.fullname}</td>
        </tr>
    </c:forEach>
    <tr>
        <th colspan="5">New purchase</th>
    </tr>
    <tr>
        <th></th>
        <th>Date</th>
        <th>Quantity</th>
        <th>Price/${product.unit}</th>
        <th>Input by</th>
    </tr>

    <form method="post">
        <tr>
            <td>*</td>
            <td>
                <c:set var="now" value="${class.java.util.Date.new$0}"/>
                <select id="purchaseDate-dd" name="purchaseDate-dd">
                    <c:forEach var="date" begin="1" end="31" step="1">
                        <option value="${date}" ${date==now.date?"selected":""}>${class.sgt.supermarket.util.DateExtensions.getDateString$[date]}</option>
                    </c:forEach>

                </select>
                <select id="purchaseDate-mm" name="purchaseDate-mm">
                    <c:forEach var="month" begin="1" end="12" step="1">
                        <option value="${month}" ${month==now.month+1?"selected":""}>${class.sgt.supermarket.util.DateExtensions.getMonthString$[month]}</option>
                    </c:forEach>
                </select>
                <select class="split-date range-low-19000101 range-high-<fmt:formatDate value="${now}" pattern="yyyyMMdd"/> id="purchaseDate" name="purchaseDate">
                        <c:forEach var="year" begin="${now.year-1}" end="${now.year}" step="1">
                            <option value="${year+1900}" ${year==now.year?"selected":""}>${year+1900}</option>
                        </c:forEach>
                </select>
            </td>
            <td><input name="quantity" size="5" type="text" value="" /></td>
            <td><input name="price" size="5" type="text" value="" /></td>
            <td>${pageContext.request.remoteUser}</td>
        </tr>
        <tr>
            <td colspan="5"><input type="submit" name="add" value="Add" /></td>
        </tr>
    </form>
</table>
